<?php


require_once FRAMEWORK_DIR."/libraries/neocasta/registry.php";

class RegistryTestCaseOutput extends UnitTestCase {

	function setUp() {
        $registry = &NRegistry::getInstance();
        $registry->save();
    }
    function tearDown() {
        $registry = &NRegistry::getInstance();
        $registry->restore();
    }

	function testAccess() {
        $registry = &new NRegistry();
        $this->assertFalse($registry->isEntry('a'));
        $this->assertNull($registry->getEntry('a'));
        $thing = 'thing';
        $registry->setEntry('a', $thing);
        $this->assertTrue($registry->isEntry('a'));
        $this->assertReference($registry->getEntry('a'), $thing);
    }
    function testSingleton() {
        $this->assertReference(
                NRegistry::getInstance(),
                NRegistry::getInstance());
        $this->assertIsA(NRegistry::getInstance(), 'NRegistry');
    }

function testSaveAndRestore() {
        $registry = &new NRegistry();
        $a = 'a';
        $registry->setEntry('a', $a);
        $registry->save();
        $this->assertFalse($registry->isEntry('a'));
        $b = 'b';
        $registry->setEntry('a', $b);
        $this->assertReference($registry->getEntry('a'), $b);
        $registry->restore();
        $this->assertReference($registry->getEntry('a'), $a);
    }


}


?>